<<<<<<< HEAD ======= >>>>>>> rami-dev <<<<<<< HEAD ======= >>>>>>> rami-dev

Row

confirmed

<<<<<<< HEAD 14,288,689 ======= 21,159,730 >>>>>>> rami-dev

active

<<<<<<< HEAD 5,659,100 (39.6%) ======= 7,118,216 (33.6%) >>>>>>> rami-dev

recovered

<<<<<<< HEAD 8,027,451 (56.2%) ======= 13,276,831 (62.7%) >>>>>>> rami-dev

death

<<<<<<< HEAD 602,138 (4.2%)

Row

Cases Distribution by Type (Top 25 Countries)

Row

Daily Cumulative Cases by Type

Recovery and Death Rates by Country

======= 764,683 (3.6%)

Row

Cases Distribution by Type (2020-08-14)

>>>>>>> rami-dev

Daily Cumulative Cases

<<<<<<< HEAD

Data

About

The Coronavirus Dashboard

Last updated: 18 July

This Coronavirus dashboard provides an overview of the 2019 Novel Coronavirus COVID-19 (2019-nCoV) epidemic. This dashboard is built with R using the Rmakrdown framework and can easily reproduce by others. The code behind the dashboard available here

=======

Recovery/Death Ratio

Map

Data

Total Number of Covid19 Cases by Country

Clich on the columns names to resort the table
Data last updated on 2020-08-14

About

The Coronavirus Dashboard

This Coronavirus dashboard provides an overview of the 2019 Novel Coronavirus COVID-19 (2019-nCoV) epidemic. This dashboard is built with R using the Rmakrdown using flexdashboard framework and can easily reproduce by others. The code behind the dashboard available here

>>>>>>> rami-dev

Data

The input data for this dashboard is the coronavirus R package (dev version). The data and dashboard is refreshed on a daily bases. The raw data pulled from the Johns Hopkins University Center for Systems Science and Engineering (JHU CCSE) Coronavirus repository

Packages

Deployment and reproducibly

The dashboard was deployed to Github docs. If you wish to deploy and/or modify the dashboard on your Github account, you can apply the following steps:

For any question or feedback, you can either open an issue or contact me on Twitter.

Contribution

The Map tab was contributed by Art Steinmetz on this pull request. Thanks Art!

---
title: "Coronavirus Dashboard"
output: 
  flexdashboard::flex_dashboard:
    orientation: rows
    social: menu
    source_code: embed
    vertical_layout: fill
---

```{r setup, include=FALSE}
#------------------ Packages ------------------
library(flexdashboard)
<<<<<<< HEAD
library(leaflet)
library(leafpop)
library(purrr)

library(coronavirus)
library(covid19italy)

data(coronavirus)
data(italy_total)
=======

>>>>>>> rami-dev

`%>%` <- magrittr::`%>%`
#------------------ Parameters ------------------
# Set colors
# https://www.w3.org/TR/css-color-3/#svg-color
confirmed_color <- "purple"
active_color <- "#1f77b4"
recovered_color <- "forestgreen"
death_color <- "red"
#------------------ Data ------------------
<<<<<<< HEAD
df <- coronavirus %>% 
  # dplyr::filter(date == max(date)) %>%
  dplyr::group_by(country, type) %>%
  dplyr::summarise(total = sum(cases)) %>%
  tidyr::pivot_wider(names_from =  type, 
                     values_from = total) %>%
  dplyr::mutate(unrecovered = confirmed - ifelse(is.na(recovered), 0, recovered) - ifelse(is.na(death), 0, death)) %>%
  dplyr::arrange(-confirmed) %>%
  dplyr::ungroup() %>%
  dplyr::mutate(country = dplyr::if_else(country == "United Arab Emirates", "UAE", country)) %>%
  dplyr::mutate(country = dplyr::if_else(country == "Mainland China", "China", country)) %>%
  dplyr::mutate(country = dplyr::if_else(country == "North Macedonia", "N.Macedonia", country)) %>%
  dplyr::mutate(country = trimws(country)) %>%
  dplyr::mutate(country = factor(country, levels = country))
=======
df <- read.csv("https://raw.githubusercontent.com/RamiKrispin/coronavirus/master/csv/coronavirus.csv", stringsAsFactors = FALSE) %>%
  dplyr::mutate(country = ifelse(country == "United Arab Emirates", "UAE", country),
                country = ifelse(country == "Mainland China", "China", country),
                country = ifelse(country == "North Macedonia", "N.Macedonia", country),
                country = trimws(country),
                country = factor(country, levels = unique(country)))

>>>>>>> rami-dev

df_daily <- df %>% 
  dplyr::group_by(date, type) %>%
  dplyr::summarise(total = sum(cases, na.rm = TRUE),
                   .groups = "drop") %>%
  tidyr::pivot_wider(names_from = type,
                     values_from = total) %>%
  dplyr::arrange(date) %>%
  dplyr::ungroup() %>%
  dplyr::mutate(active =  confirmed - death - recovered) %>%
  dplyr::mutate(confirmed_cum = cumsum(confirmed),
                death_cum = cumsum(death),
                recovered_cum = cumsum(recovered),
                active_cum = cumsum(active))


df_tree <- df %>%
  dplyr::group_by(country, type) %>%
  dplyr::summarise(total = sum(cases), .groups = "drop") %>%
  dplyr::mutate(type = ifelse(type == "confirmed", "Confirmed", type),
                type = ifelse(type == "recovered", "Recovered", type),
                type = ifelse(type == "death", "Death", type)) %>%
  tidyr::pivot_wider(names_from = type, values_from = total) %>%
  dplyr::mutate(Active = Confirmed - Death - Recovered) %>%
  tidyr::pivot_longer(cols = -country, names_to = "type", values_to = "total")

df_world <- df_tree %>%
  dplyr::group_by(type) %>%
  dplyr::summarise(total = sum(total), .groups = "drop") %>%
  tidyr::pivot_wider(names_from = type, values_from = total)

names(df_world) <- tolower(names(df_world))


#------------trajectory plot data prep------------

df_china <- coronavirus %>% dplyr::filter(type == "confirmed", country == "China") %>%
  dplyr::group_by(date) %>%
  dplyr::summarise(cases = sum(cases)) %>%
  dplyr::ungroup() %>%
  dplyr::arrange(date) %>%
  dplyr::mutate(china = cumsum(cases)) %>%
  dplyr::filter(china > 100)  %>%
  dplyr::select(-cases, -date)
df_china$index <- 1:nrow(df_china)


df_uk <- coronavirus %>% dplyr::filter(type == "confirmed", country == "United Kingdom") %>%
  dplyr::group_by(date) %>%
  dplyr::summarise(cases = sum(cases)) %>%
  dplyr::ungroup() %>%
  dplyr::arrange(date) %>%
  dplyr::mutate(uk = cumsum(cases)) %>%
  dplyr::filter(uk > 100)  %>%
  dplyr::select(-cases, -date)
df_uk$index <- 1:nrow(df_uk)


df_fr <- coronavirus %>% dplyr::filter(type == "confirmed", country == "France") %>%
  dplyr::group_by(date) %>%
  dplyr::summarise(cases = sum(cases)) %>%
  dplyr::ungroup() %>%
  dplyr::arrange(date) %>%
  dplyr::mutate(france = cumsum(cases)) %>%
  dplyr::filter(france > 100)  %>%
  dplyr::select(-cases, -date)
df_fr$index <- 1:nrow(df_fr)

df_us <- coronavirus %>% dplyr::filter(type == "confirmed", country == "US") %>%
  dplyr::group_by(date) %>%
  dplyr::summarise(cases = sum(cases)) %>%
  dplyr::ungroup() %>%
  dplyr::arrange(date) %>%
  dplyr::mutate(us = cumsum(cases)) %>%
  dplyr::filter(us > 100)  %>%
  dplyr::select(-cases, -date)
df_us$index <- 1:nrow(df_us)

df_iran <- coronavirus %>% dplyr::filter(type == "confirmed", country == "Iran") %>%
  dplyr::group_by(date) %>%
  dplyr::summarise(cases = sum(cases)) %>%
  dplyr::ungroup() %>%
  dplyr::arrange(date) %>%
  dplyr::mutate(iran = cumsum(cases)) %>%
  dplyr::filter(iran > 100)  %>%
  dplyr::select(-cases, -date)
df_iran$index <- 1:nrow(df_iran)

df_sk <- coronavirus %>% dplyr::filter(type == "confirmed", country == "Korea, South") %>%
  dplyr::group_by(date) %>%
  dplyr::summarise(cases = sum(cases)) %>%
  dplyr::ungroup() %>%
  dplyr::arrange(date) %>%
  dplyr::mutate(sk = cumsum(cases)) %>%
  dplyr::filter(sk > 100)  %>%
  dplyr::select(-cases, -date)
df_sk$index <- 1:nrow(df_sk)

df_spain <- coronavirus %>% dplyr::filter(type == "confirmed", country == "Spain") %>%
  dplyr::group_by(date) %>%
  dplyr::summarise(cases = sum(cases)) %>%
  dplyr::ungroup() %>%
  dplyr::arrange(date) %>%
  dplyr::mutate(spain = cumsum(cases)) %>%
  dplyr::filter(spain > 100)  %>%
  dplyr::select(-cases, -date)
df_spain$index <- 1:nrow(df_spain)



df_italy <- italy_total %>% dplyr::select(date, italy = cumulative_cases) %>%
  dplyr::filter(italy > 100) %>%
  dplyr::select(-date)
df_italy$index <- 1:nrow(df_italy)

df_trajectory <- df_china %>% 
  dplyr::left_join(df_italy, by = "index") %>%
  dplyr::left_join(df_iran, by = "index") %>%
  dplyr::left_join(df_sk, by = "index") %>%
  dplyr::left_join(df_us, by = "index") %>%
  dplyr::left_join(df_fr, by = "index") %>%
  dplyr::left_join(df_uk, by = "index") %>%
  dplyr::left_join(df_spain, by = "index")



```


<<<<<<< HEAD
Summary
=======================================================================
=======
>>>>>>> rami-dev
Row
-----------------------------------------------------------------------

### confirmed {.value-box}

```{r}

valueBox(value = paste(format(df_world$confirmed, big.mark = ","), "", sep = " "), 
         caption = "Total Confirmed Cases", 
         icon = "fas fa-user-md", 
         color = confirmed_color)
```


### active {.value-box}

```{r}
valueBox(value = paste(format(df_world$active[1], big.mark = ","), " (",
                       round(100 * df_world$active[1] / df_world$confirmed[1], 1), 
                       "%)", sep = ""), 
         caption = "Active Cases", icon = "fas fa-ambulance", 
         color = active_color)
```

### recovered {.value-box}

```{r}
valueBox(value = paste(format(df_world$recovered[1] , big.mark = ","), " (",
                       round(100 * df_world$recovered[1] / df_world$confirmed[1], 1), 
                       "%)", sep = ""), 
         caption = "Recovered Cases", icon = "fas fa-heartbeat", 
         color = recovered_color)
```

### death {.value-box}

```{r}

valueBox(value = paste(format(df_world$death[1] , big.mark = ","), " (",
                       round(100 * df_world$death[1] / df_world$confirmed[1], 1), 
                       "%)", sep = ""),
         caption = "Death Cases", 
         icon = "fas fa-heart-broken", 
         color = death_color)
```


Row {.tabset}
-----------------------------------------------------------------------

<<<<<<< HEAD
### Cases Distribution by Type (Top 25 Countries) 
=======
### Cases Distribution by Type (`r  max(df$date)`)
>>>>>>> rami-dev

```{r daily_summary}


<<<<<<< HEAD
plotly::plot_ly(data = df[1:30,], 
                x = ~ country, 
                y = ~ unrecovered, 
                # text =  ~ confirmed, 
                # textposition = 'auto',
                type = "bar", 
                name = "Active",
                marker = list(color = active_color)) %>%
  plotly::add_trace(y = ~ recovered, 
                    # text =  ~ recovered, 
                    # textposition = 'auto',
                    name = "Recovered",
                    marker = list(color = recovered_color)) %>%
  plotly::add_trace(y = ~ death, 
                    # text =  ~ death, 
                    # textposition = 'auto',
                    name = "Death",
                    marker = list(color = death_color)) %>%
  plotly::layout(title = "",
                 barmode = 'stack',
                 yaxis = list(title = "Total Cases (log scaled)",
                              type = "log"),
                 xaxis = list(title = paste("Last update:", format(max(coronavirus::coronavirus$date), '%d %B'), sep = " ")),
                 hovermode = "compare",
                 annotations = list(
                   text = paste("Last update:", format(max(coronavirus::coronavirus$date), '%d %B'), sep = " "),
                   xref = "paper",
                   yref = "paper",
                   showarrow = FALSE,
                  x = 0.95,
                  y = 1
                 ),
                 margin =  list(
                   # l = 60,
                   # r = 40,
                   b = 10,
                   t = 10,
                   pad = 2
                 ))

=======
plotly::plot_ly(
  data = df_tree %>% dplyr::filter(type == "Confirmed"),
  type= "treemap",
  values = ~total,
  labels= ~ country,
  parents=  ~type,
  domain = list(column=0),
  name = "Confirmed",
  textinfo="label+value+percent parent"
) %>%
  plotly::add_trace(
    data = df_tree %>% dplyr::filter(type == "Active"),
    type= "treemap",
    values = ~total,
    labels= ~ country,
    parents=  ~type,
    domain = list(column=1),
    name = "Active",
    textinfo="label+value+percent parent"
  ) %>%
  plotly::add_trace(
    data = df_tree %>% dplyr::filter(type == "Recovered"),
    type= "treemap",
    values = ~total,
    labels= ~ country,
    parents=  ~type,
    domain = list(column=2),
    name = "Recovered",
    textinfo="label+value+percent parent"
  ) %>%
  plotly::add_trace(
    data = df_tree %>% dplyr::filter(type == "Death"),
    type= "treemap",
    values = ~total,
    labels= ~ country,
    parents=  ~type,
    domain = list(column=3),
    name = "Death",
    textinfo="label+value+percent parent"
  ) %>%
  plotly::layout(grid=list(columns=4, rows=1))
  
>>>>>>> rami-dev




```

### Daily Cumulative Cases
    
```{r}
<<<<<<< HEAD

# plotly::plot_ly(df_daily, x = ~date, y = ~active_cum, name = 'Active', type = 'scatter', mode = 'none', stackgroup = 'one', fillcolor = "#1f77b4") %>%
# plotly::add_trace(y = ~recovered_cum, name = 'Recovered', fillcolor = "green") %>%
# plotly::add_trace(y = ~death_cum, name = "Death", fillcolor = "red") %>%
#   plotly::layout(title = "",
#          xaxis = list(title = "",
#                       showgrid = FALSE),
#          yaxis = list(title = "Cumulative Number of Cases",
#                       showgrid = FALSE),
#          legend = list(x = 0.1, y = 0.9),
#                  hovermode = "compare")


=======
>>>>>>> rami-dev
plotly::plot_ly(data = df_daily,
                x = ~ date,
                y = ~ active_cum, 
                name = 'Active', 
                fillcolor = active_color,
                type = 'scatter',
                mode = 'none', 
                stackgroup = 'one') %>%
  plotly::add_trace(y = ~ recovered_cum,
                    name = "Recovered",
                    fillcolor = recovered_color) %>%
  plotly::add_trace(y = ~ death_cum,
                    name = "Death",
                    fillcolor = death_color) %>%
  plotly::layout(title = "",
                 yaxis = list(title = "Cumulative Number of Cases"),
                 xaxis = list(title = "Date",
                              type = "date"),
                 legend = list(x = 0.1, y = 0.9),
                 hovermode = "compare")

```




### Recovery/Death Ratio

```{r}
<<<<<<< HEAD
df_summary <-coronavirus %>% 
  # dplyr::filter(country != "Others") %>%
=======
df %>% 
  
>>>>>>> rami-dev
  dplyr::group_by(country, type) %>%
  dplyr::summarise(total_cases = sum(cases)) %>%
  tidyr::pivot_wider(names_from = type, values_from = total_cases) %>%
  dplyr::arrange(- confirmed) %>%
<<<<<<< HEAD
  dplyr::filter(confirmed >= 25) %>%
  dplyr::select(country = country, confirmed, recovered, death) %>%
=======
  dplyr::filter(confirmed >= 20000) %>%
>>>>>>> rami-dev
  dplyr::mutate(recover_rate = recovered / confirmed,
                death_rate = death / confirmed) %>% 
  dplyr::mutate(recover_rate = dplyr::if_else(is.na(recover_rate), 0, recover_rate),
                death_rate = dplyr::if_else(is.na(death_rate), 0, death_rate)) %>%
  dplyr::ungroup() %>%
  dplyr::mutate(confirmed_normal = as.numeric(confirmed) / max(as.numeric(confirmed))) %>%
  plotly::plot_ly(y = ~ round(100 * recover_rate, 1),
                  x = ~ round(100 * death_rate, 1),
                  size = ~  log(confirmed),
                  sizes = c(5, 70),
                  type = 'scatter', mode = 'markers',
                  color = ~ country,
                  marker = list(sizemode = 'diameter' , opacity = 0.5),
                  hoverinfo = 'text',
                  text = ~paste("
", country, "
Confirmed Cases: ", confirmed, "
Recovery Rate: ", paste(round(100 * recover_rate, 1), "%", sep = ""), "
Death Rate: ", paste(round(100 * death_rate, 1), "%", sep = "")) ) %>% plotly::layout(title = "Recovery / Death Ratio (Countries with More than 20,000 Cases)", yaxis = list(title = "Recovery Rate", ticksuffix = "%"), xaxis = list(title = "Death Rate", ticksuffix = "%", dtick = 1, tick0 = 0), hovermode = "compare") ``` ### Map ```{r map} # map tab added by Art Steinmetz <<<<<<< HEAD cv_data_for_plot <- coronavirus %>% dplyr::filter(cases > 0) %>% dplyr::group_by(country,province,lat,long,type) %>% dplyr::summarise(cases = sum(cases)) %>% dplyr::mutate(log_cases = 2 * log(cases)) %>% dplyr::ungroup() ======= library(leaflet) library(leafpop) library(dplyr) library(purrr) cv_data_for_plot <- df %>% filter(cases > 0) %>% group_by(country,province,lat,long,type) %>% summarise(cases = sum(cases)) %>% mutate(log_cases = 2 * log(cases)) %>% ungroup() >>>>>>> rami-dev cv_data_for_plot.split <- cv_data_for_plot %>% split(cv_data_for_plot$type) pal <- colorFactor(c("orange", "red","green"), domain = c("confirmed", "death","recovered")) map_object <- leaflet() %>% addProviderTiles(providers$Stamen.Toner) names(cv_data_for_plot.split) %>% purrr::walk( function(df) { map_object <<- map_object %>% addCircleMarkers(data=cv_data_for_plot.split[[df]], lng=~long, lat=~lat, # label=~as.character(cases), color = ~pal(type), stroke = FALSE, fillOpacity = 0.8, radius = ~log_cases, # popup = leafpop::popupTable(cv_data_for_plot.split[[df]], popup = popupTable(cv_data_for_plot.split[[df]], feature.id = FALSE, row.numbers = FALSE, zcol=c("type","cases","country","province")), group = df, # clusterOptions = markerClusterOptions(removeOutsideVisibleBounds = F), labelOptions = labelOptions(noHide = F, direction = 'auto')) }) map_object %>% addLayersControl( overlayGroups = names(cv_data_for_plot.split), options = layersControlOptions(collapsed = FALSE) ) ``` ### Data <<<<<<< HEAD Column {data-width=400} ------------------------------------- ### New Cases - Top 15 Countries (`r max(coronavirus$date)`) ```{r new_cases} max_date <- max(coronavirus$date) coronavirus %>% dplyr::filter(type == "confirmed", date == max_date) %>% dplyr::group_by(country) %>% dplyr::summarise(total_cases = sum(cases)) %>% dplyr::arrange(-total_cases) %>% dplyr::mutate(country = factor(country, levels = country)) %>% dplyr::ungroup() %>% dplyr::top_n(n = 15, wt = total_cases) %>% plotly::plot_ly(x = ~ country, y = ~ total_cases, text = ~ total_cases, textposition = 'auto', type = "bar") %>% plotly::layout(yaxis = list(title = "Number of Cases"), xaxis = list(title = ""), margin = list( l = 10, r = 10, b = 10, t = 10, pad = 2 )) ``` ### Trajectory Plot - Major Countries ```{r} plotly::plot_ly(data = df_trajectory) %>% plotly::add_lines(x = ~ index, y = ~ china, name = "China", line = list(width = 2)) %>% plotly::add_lines(x = ~ index, y = ~ italy, line = list(color = "red", width = 2), name = "Italy") %>% plotly::add_lines(x = ~ index, y = ~ us, name = "United States", line = list(width = 2)) %>% plotly::add_lines(x = ~ index, y = ~ uk, name = "United Kingdom", line = list(width = 2)) %>% plotly::add_lines(x = ~ index, y = ~ france, name = "France", line = list(width = 2)) %>% plotly::add_lines(x = ~ index, y = ~ iran, name = "Iran", line = list(color = "orange", width = 2)) %>% plotly::add_lines(x = ~ index, y = ~ sk, name = "South Korea", line = list(width = 2)) %>% plotly::add_lines(x = ~ index, y = ~ spain, name = "Spain") %>% plotly::layout(yaxis = list(title = "Cumulative Positive Cases",type = "log"), xaxis = list(title = "Days since the total positive cases surpass 100"), legend = list(x = 0.7, y = 0.3), hovermode = "compare") ``` Column {data-width=600} ------------------------------------- ### Recovery and Death Rates for Countries with at Least 10000 Cases ```{r} coronavirus::coronavirus %>% # dplyr::filter(country != "Others") %>% dplyr::group_by(country, type) %>% dplyr::summarise(total_cases = sum(cases)) %>% tidyr::pivot_wider(names_from = type, values_from = total_cases) %>% dplyr::arrange(- confirmed) %>% dplyr::filter(confirmed >= 10000) %>% dplyr::mutate(recover_rate = recovered / confirmed, death_rate = death / confirmed) %>% dplyr::mutate(recover_rate = dplyr::if_else(is.na(recover_rate), 0, recover_rate), death_rate = dplyr::if_else(is.na(death_rate), 0, death_rate)) %>% dplyr::ungroup() %>% dplyr::mutate(confirmed_normal = as.numeric(confirmed) / max(as.numeric(confirmed))) %>% plotly::plot_ly(y = ~ round(100 * recover_rate, 1), x = ~ round(100 * death_rate, 1), size = ~ log(confirmed), sizes = c(5, 70), type = 'scatter', mode = 'markers', color = ~ country, marker = list(sizemode = 'diameter' , opacity = 0.5), hoverinfo = 'text', text = ~paste("
", country, "
Confirmed Cases: ", confirmed, "
Recovery Rate: ", paste(round(100 * recover_rate, 1), "%", sep = ""), "
Death Rate: ", paste(round(100 * death_rate, 1), "%", sep = "")) ) %>% plotly::layout(yaxis = list(title = "Recovery Rate", ticksuffix = "%"), xaxis = list(title = "Death Rate", ticksuffix = "%", dtick = 1, tick0 = 0), hovermode = "compare") ``` ### Cases Status Update for `r max(coronavirus$date)` ```{r} daily_summary <- coronavirus %>% dplyr::filter(date == max(date)) %>% dplyr::group_by(country, type) %>% dplyr::summarise(total = sum(cases)) %>% tidyr::pivot_wider(names_from = type, values_from = total) %>% dplyr::arrange(-confirmed) %>% dplyr::select(country = country, confirmed, recovered, death) DT::datatable(data = daily_summary, rownames = FALSE, colnames = c("Country", "Confirmed", "Recovered", "Death"), options = list(pageLength = nrow(daily_summary), dom = 'tip')) ``` Data ======================================================================= ```{r} coronavirus %>% dplyr::select(Date = date, Province = province, Country = country, `Case Type` = type, `Number of Cases` = cases) %>% DT::datatable(rownames = FALSE, options = list(searchHighlight = TRUE, pageLength = 20), filter = 'top') ``` About ======================================================================= **The Coronavirus Dashboard** Last updated: `r format(max(coronavirus::coronavirus$date), '%d %B')` This Coronavirus dashboard provides an overview of the 2019 Novel Coronavirus COVID-19 (2019-nCoV) epidemic. This dashboard is built with R using the Rmakrdown framework and can easily reproduce by others. The code behind the dashboard available [here](https://github.com/RamiKrispin/coronavirus_dashboard) ======= ```{r} df_rates <- df_tree %>% dplyr::filter(type != "Active") %>% tidyr::pivot_wider(names_from = "type", values_from = "total") %>% dplyr::mutate(recovery_rate = Recovered / Confirmed, death_rate = Death / Confirmed) bar_chart <- function(label, width = "100%", height = "14px", fill = "#00bfc4", background = NULL) { bar <- htmltools::div(style = list(background = fill, width = width, height = height)) chart <- htmltools::div(style = list(flexGrow = 1, marginLeft = "6px", background = background), bar) htmltools::div(style = list(display = "flex", alignItems = "center"), label, chart) } tbl <- reactable::reactable(df_rates, pagination = FALSE, highlight = TRUE, height = 400, sortable = TRUE, borderless = TRUE, defaultPageSize = nrow(df_rates), defaultSortOrder = "desc", defaultSorted = "Confirmed", columns = list( country = reactable::colDef(name = "Country", minWidth = 50, maxWidth = 100), Confirmed = reactable::colDef(name = "Confirmed", minWidth = 50, maxWidth = 100, defaultSortOrder = "desc"), Recovered = reactable::colDef(name = "Recovered", minWidth = 50, maxWidth = 100), Death = reactable::colDef(name = "Death", minWidth = 50, maxWidth = 100), recovery_rate = reactable::colDef(name = "Recovery Rate", minWidth = 50, maxWidth = 200, defaultSortOrder = "desc", cell = function(value) { # Format as percentages with 1 decimal place value <- paste0(format(round(value * 100, 2), nsmall = 1), "%") bar_chart(value, width = value, fill = "green", background = "#e1e1e1") }, align = "left"), death_rate = reactable::colDef(name = "Death Rate", minWidth = 50, maxWidth = 200, defaultSortOrder = "desc", cell = function(value) { # Format as percentages with 1 decimal place value <- paste0(format(round(value * 100, 2), nsmall = 1), "%") bar_chart(value, width = value, fill = "red", background = "#e1e1e1") }, align = "left")) ) library(htmltools) htmltools::div(class = "standings", htmltools::div(class = "title", htmltools::h2("Total Number of Covid19 Cases by Country"), "Clich on the columns names to resort the table" ), tbl, paste("Data last updated on", max(df$date)) ) ``` ### About **The Coronavirus Dashboard** This Coronavirus dashboard provides an overview of the 2019 Novel Coronavirus COVID-19 (2019-nCoV) epidemic. This dashboard is built with R using the [Rmakrdown](https://rmarkdown.rstudio.com/) using [flexdashboard](https://rmarkdown.rstudio.com/flexdashboard/) framework and can easily reproduce by others. The code behind the dashboard available [here](https://github.com/RamiKrispin/coronavirus_dashboard) >>>>>>> rami-dev **Data** The input data for this dashboard is the [coronavirus](https://github.com/RamiKrispin/coronavirus) R package (dev version). The data and dashboard is refreshed on a daily bases. The raw data pulled from the Johns Hopkins University Center for Systems Science and Engineering (JHU CCSE) Coronavirus [repository](https://github.com/RamiKrispin/coronavirus-csv) **Packages** * Dashboard interface - the [flexdashboard](https://rmarkdown.rstudio.com/flexdashboard/) package. <<<<<<< HEAD * Visualization - the [plotly](https://plot.ly/r/) package for the plots and [leaflet](https://rstudio.github.io/leaflet/) for the map * Data manipulation - [dplyr](https://dplyr.tidyverse.org/), and [tidyr](https://tidyr.tidyverse.org/) * Tables - the [DT](https://rstudio.github.io/DT/) package ======= * Visualization - the [plotly](https://plot.ly/r/) package * Data manipulation - [dplyr](https://dplyr.tidyverse.org/), [tidyr](https://tidyr.tidyverse.org/), and [purrr](https://purrr.tidyverse.org/) packages * Mapping - [leaflet](https://rstudio.github.io/leaflet/) and [leafpop](https://github.com/r-spatial/leafpop) packages * Tables - the [reactable](https://glin.github.io/reactable/) package >>>>>>> rami-dev **Deployment and reproducibly** The dashboard was deployed to Github docs. If you wish to deploy and/or modify the dashboard on your Github account, you can apply the following steps: * Fork the dashboard [repository](https://github.com/RamiKrispin/coronavirus_dashboard), or * Clone it and push it to your Github package * Here some general guidance about deployment of flexdashboard on Github page - [link](https://github.com/pbatey/flexdashboard-example) For any question or feedback, you can either open an [issue](https://github.com/RamiKrispin/coronavirus_dashboard/issues) or contact me on [Twitter](https://twitter.com/Rami_Krispin). <<<<<<< HEAD **Contribution** The **Map** tab was contributed by [Art Steinmetz](@adababbage) on this [pull request](https://github.com/RamiKrispin/coronavirus_dashboard/pull/1). Thanks Art! ======= >>>>>>> rami-dev